//
//  Socket.m
//  EFExtend
//
//  Created by mac on 15/6/28.
//  Copyright (c) 2015年 Eric. All rights reserved.
//

#import "Socket.h"
#import "Connect.h"
#import "Listen.h"

@interface Socket ()
@property (strong, nonatomic) Connect *  connect;
@property (strong, nonatomic) Listen *  listen;
@end

@implementation Socket

- (void)dealloc
{
   
    HM_SUPER_DEALLOC();
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    [self.customNavLeftBtn setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
    [self.customNavLeftBtn setFrame:CGRectMakeBound(32, 32)];
    
    [self.customNavRightBtn setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
    [self.customNavRightBtn setFrame:CGRectMakeBound(32, 32)];
    
    self.connect = [[Connect alloc]init];
    self.connect.videoPort = 10000;
    self.connect.videoHost = @"222.77.181.68";
    self.connect.TCPPort = 8000;
    self.connect.TCPHost = @"localhost";//@"222.77.181.68";
    self.connect.deviceId = @"00000000000000000520";
    
    self.listen = [[Listen alloc]init];
    self.listen.videoPort = 8000;
    
    [[[[[[UIView viewAsButten]
     EFTagString:@"connect"] EFText:@"connect"] EFTextColor:[UIColor blueColor]]
     EFOwner:self.view] mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_top).offset(10);
        make.left.mas_equalTo(self.view.mas_left).offset(0);
        make.height.mas_equalTo(40);
        make.right.mas_equalTo(self.view.mas_right).offset(0);
    }];
    
    [[[[[[UIView viewAsButten]
         EFTagString:@"listen"] EFText:@"listen"] EFTextColor:[UIColor blueColor]]
      EFOwner:self.view] mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_top).offset(60);
        make.left.mas_equalTo(self.view.mas_left).offset(0);
        make.height.mas_equalTo(40);
        make.right.mas_equalTo(self.view.mas_right).offset(0);
    }];
    
    

}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

ON_Button(signal){
    UIButten *btn = signal.source;
    if ([signal is:[UIButten TOUCH_UP_INSIDE]]) {
        if ([btn is:@"leftBtn"]) {//customNavLeftBtn
            [self.listen deaction];
            [self.connect deaction];
            [self backAndRemoveWithAnimate:YES];
        }else if ([btn is:@"listen"]){//customNavRightBtn

            [self.listen action];
            
        }else if ([btn is:@"connect"]){//customNavRightBtn
            
            [self.connect action];
            
        }
    }
}



@end
